import { defineStore } from 'pinia'
import axios from 'axios'
import {nanoid} from 'nanoid';

/* export const useTalkListStore = defineStore('loveTalk', {
    state: () => {
        return {
            talkList: JSON.parse(localStorage.getItem('talkList') || '[]')
        }
    },
    actions: {
        async addTalk() {
            let {data:{content:title}} = await axios.get('https://api.uomg.com/api/rand.qinghua?format=json')
            this.talkList.push({id: nanoid(), title})
        }
    }
}); */
import {reactive} from 'vue'
 export const useTalkListStore = defineStore('loveTalk', ()=>{ 
    return { 
        talkList: reactive(JSON.parse(localStorage.getItem('talkList') || '[]')),
        async addTalk() {
            let {data:{content:title}} = await axios.get('https://api.uomg.com/api/rand.qinghua?format=json')
            this.talkList.push({id: nanoid(), title})
        }
    }
});